package com.longge;

public class CountGoodTriplets {

    public int countGoodTriplets(int[] arr, int a, int b, int c) {

        int ans = 0;
        for (int i = 0; i < arr.length; i++) {
            for (int j = i + 1; j < arr.length; j++) {
                if (Math.abs(arr[i] - arr[j]) <= a) {
                    for (int z = j + 1; z < arr.length; z++) {
                        if (Math.abs(arr[i] - arr[z]) <= c && Math.abs(arr[j] - arr[z]) <= b) {
                            ans++;
                        }
                    }
                }

            }
        }
        return ans;

    }
}
